package io.demo.message.serial;

import java.io.Serializable;
import org.apache.commons.lang3.SerializationUtils;

/**
 * Serialization provided by JDK
 *
 * @param <T> Any type that extends {@link java.io.Serializable}
 */
public class JdkSerializedObject<T extends Serializable> extends SerializedObject<T> {

  JdkSerializedObject(T object) {
    super(object);
  }

  @Override
  protected void beforeSerialize() {
    // empty
  }

  @Override
  protected byte[] doSerialization(T object) {
    return SerializationUtils.serialize(object);
  }

  @Override
  public T reverse() {
    return SerializationUtils.deserialize(getByteArray());
  }
}
